<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>

  <div id="app">
    <ul>
      <li v-for="item in datalist">{{item.name}}-{{item.num}}</li>
    </ul>
    <hr>
    {{total}}
  </div>

  <script>

    const vm = new Vue({
      el: "#app",
      data: {
        datalist: []
      },
      created() {
        fetch('http://localhost:8088/api/cities').then(res => res.json()).then((res) => {
          console.log(res)
          this.datalist=res;
        })
      },
      computed: {
        total() {
          let rs = this.datalist.reduce((count, item) => count += parseInt(item.num), 0)
          return rs;
        }
      }
    })

  </script>

</body>

</html>